package com.lixw.saa.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: ChatClientController
 * @Description:
 * @Author: xuweiLi
 * @Create: 2025/10/2 13:57
 **/
@RestController
public class ChatClientController {

    @Autowired
    private ChatClient chatClient;

    @GetMapping("/chatclient/dochat")
    public String doChat(@RequestParam(name = "msg",defaultValue = "2加4等于几") String msg)
    {
        String result = chatClient.prompt().user(msg).call().content();
        System.out.println("响应：" + result);
        return result;
    }
}